package com.innovation.chengzhangriji;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import de.greenrobot.dao.AbstractDaoMaster;
import de.greenrobot.dao.identityscope.IdentityScopeType;

import com.innovation.chengzhangriji.BabyAndParentDao;
import com.innovation.chengzhangriji.ParentDao;
import com.innovation.chengzhangriji.BabyDao;
import com.innovation.chengzhangriji.MessageDao;
import com.innovation.chengzhangriji.TimelineDao;
import com.innovation.chengzhangriji.TimelineServerTimeDao;
import com.innovation.chengzhangriji.TimelineLastServerTimeDao;
import com.innovation.chengzhangriji.TimelineTextDao;
import com.innovation.chengzhangriji.TimelinePhotoDao;
import com.innovation.chengzhangriji.TimelinePhotoUrlDao;
import com.innovation.chengzhangriji.TimelineAudioUrlDao;
import com.innovation.chengzhangriji.TimelineVideoScreenshotUrlDao;
import com.innovation.chengzhangriji.TimelineVideoUrlDao;
import com.innovation.chengzhangriji.TimelineMilestoneDao;
import com.innovation.chengzhangriji.TimelineDeleteDao;
import com.innovation.chengzhangriji.PublicPhotoThemeDao;
import com.innovation.chengzhangriji.PublicMilestoneDao;
import com.innovation.chengzhangriji.DiscoverSyncTimeDao;
import com.innovation.chengzhangriji.DiscoverSaveCommentDao;
import com.innovation.chengzhangriji.DiscoverDao;
import com.innovation.chengzhangriji.DiscoverPhotoDao;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * Master of DAO (schema version 13): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
    public static final int SCHEMA_VERSION = 13;

    /** Creates underlying database table using DAOs. */
    public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) {
        BabyAndParentDao.createTable(db, ifNotExists);
        ParentDao.createTable(db, ifNotExists);
        BabyDao.createTable(db, ifNotExists);
        MessageDao.createTable(db, ifNotExists);
        TimelineDao.createTable(db, ifNotExists);
        TimelineServerTimeDao.createTable(db, ifNotExists);
        TimelineLastServerTimeDao.createTable(db, ifNotExists);
        TimelineTextDao.createTable(db, ifNotExists);
        TimelinePhotoDao.createTable(db, ifNotExists);
        TimelinePhotoUrlDao.createTable(db, ifNotExists);
        TimelineAudioUrlDao.createTable(db, ifNotExists);
        TimelineVideoScreenshotUrlDao.createTable(db, ifNotExists);
        TimelineVideoUrlDao.createTable(db, ifNotExists);
        TimelineMilestoneDao.createTable(db, ifNotExists);
        TimelineDeleteDao.createTable(db, ifNotExists);
        PublicPhotoThemeDao.createTable(db, ifNotExists);
        PublicMilestoneDao.createTable(db, ifNotExists);
        DiscoverSyncTimeDao.createTable(db, ifNotExists);
        DiscoverSaveCommentDao.createTable(db, ifNotExists);
        DiscoverDao.createTable(db, ifNotExists);
        DiscoverPhotoDao.createTable(db, ifNotExists);
    }
    
    /** Drops underlying database table using DAOs. */
    public static void dropAllTables(SQLiteDatabase db, boolean ifExists) {
        BabyAndParentDao.dropTable(db, ifExists);
        ParentDao.dropTable(db, ifExists);
        BabyDao.dropTable(db, ifExists);
        MessageDao.dropTable(db, ifExists);
        TimelineDao.dropTable(db, ifExists);
        TimelineServerTimeDao.dropTable(db, ifExists);
        TimelineLastServerTimeDao.dropTable(db, ifExists);
        TimelineTextDao.dropTable(db, ifExists);
        TimelinePhotoDao.dropTable(db, ifExists);
        TimelinePhotoUrlDao.dropTable(db, ifExists);
        TimelineAudioUrlDao.dropTable(db, ifExists);
        TimelineVideoScreenshotUrlDao.dropTable(db, ifExists);
        TimelineVideoUrlDao.dropTable(db, ifExists);
        TimelineMilestoneDao.dropTable(db, ifExists);
        TimelineDeleteDao.dropTable(db, ifExists);
        PublicPhotoThemeDao.dropTable(db, ifExists);
        PublicMilestoneDao.dropTable(db, ifExists);
        DiscoverSyncTimeDao.dropTable(db, ifExists);
        DiscoverSaveCommentDao.dropTable(db, ifExists);
        DiscoverDao.dropTable(db, ifExists);
        DiscoverPhotoDao.dropTable(db, ifExists);
    }
    
    public static abstract class OpenHelper extends SQLiteOpenHelper {

        public OpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory, SCHEMA_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
            createAllTables(db, false);
        }
    }
    
    /** WARNING: Drops all table on Upgrade! Use only during development. */
    public static class DevOpenHelper extends OpenHelper {
        public DevOpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
            dropAllTables(db, true);
            onCreate(db);
        }
    }

    public DaoMaster(SQLiteDatabase db) {
        super(db, SCHEMA_VERSION);
        registerDaoClass(BabyAndParentDao.class);
        registerDaoClass(ParentDao.class);
        registerDaoClass(BabyDao.class);
        registerDaoClass(MessageDao.class);
        registerDaoClass(TimelineDao.class);
        registerDaoClass(TimelineServerTimeDao.class);
        registerDaoClass(TimelineLastServerTimeDao.class);
        registerDaoClass(TimelineTextDao.class);
        registerDaoClass(TimelinePhotoDao.class);
        registerDaoClass(TimelinePhotoUrlDao.class);
        registerDaoClass(TimelineAudioUrlDao.class);
        registerDaoClass(TimelineVideoScreenshotUrlDao.class);
        registerDaoClass(TimelineVideoUrlDao.class);
        registerDaoClass(TimelineMilestoneDao.class);
        registerDaoClass(TimelineDeleteDao.class);
        registerDaoClass(PublicPhotoThemeDao.class);
        registerDaoClass(PublicMilestoneDao.class);
        registerDaoClass(DiscoverSyncTimeDao.class);
        registerDaoClass(DiscoverSaveCommentDao.class);
        registerDaoClass(DiscoverDao.class);
        registerDaoClass(DiscoverPhotoDao.class);
    }
    
    public DaoSession newSession() {
        return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
    }
    
    public DaoSession newSession(IdentityScopeType type) {
        return new DaoSession(db, type, daoConfigMap);
    }
    
}
